fmap Seconds . annexDelayAdd <$> Annex.getGitConfig
largefilematcher <- liftAnnex largeFilesMatcher
annexdotfiles <- liftAnnex $ getGitConfigVal annexDotFiles
+ addunlockedmatcher <- liftAnnex $
+ ifM (annexSupportUnlocked <$> Annex.getGitConfig)
+ ( Just <$> addUnlockedMatcher
+ , return Nothing
+ )
msg <- liftAnnex Command.Sync.commitMsg
lockdowndir <- liftAnnex $ fromRepo gitAnnexTmpWatcherDir
liftAnnex $ do
void $ liftIO $ tryIO $ removeDirectoryRecursive lockdowndir
void $ createAnnexDirectory lockdowndir
waitChangeTime $ \(changes, time) -> do
- readychanges <- handleAdds lockdowndir havelsof largefilematcher annexdotfiles delayadd $
+ readychanges <- handleAdds lockdowndir havelsof largefilematcher annexdotfiles addunlockedmatcher delayadd $
simplifyChanges changes
if shouldCommit False time (length readychanges) readychanges
then do
- Any pending adds that are not ready yet are put back into the ChangeChan,
- where they will be retried later.
-}
-handleAdds :: OsPath -> Bool -> GetFileMatcher -> Bool -> Maybe Seconds -> [Change] -> Assistant [Change]
-handleAdds lockdowndir havelsof largefilematcher annexdotfiles delayadd cs = returnWhen (null incomplete) $ do
+handleAdds :: OsPath -> Bool -> GetFileMatcher -> Bool -> Maybe AddUnlockedMatcher -> Maybe Seconds -> [Change] -> Assistant [Change]
+handleAdds lockdowndir havelsof largefilematcher annexdotfiles addunlockedmatcher delayadd cs = returnWhen (null incomplete) $ do
let (pending, inprocess) = partition isPendingAddChange incomplete
let lockdownconfig = LockDownConfig
{ lockingFile = False
Command.Add.addFile Command.Add.Small f
=<< liftIO (R.getSymbolicLinkStatus (fromOsPath f))
- {- Avoid overhead of re-injesting a renamed unlocked file, by
- - examining the other Changes to see if a removed file has the
- - same InodeCache as the new file. If so, we can just update
+ {- When adding the file unlocked, avoid overhead of re-injesting a renamed
+ - unlocked file, by examining the other Changes to see if a removed
+ - file has the same InodeCache as the new file. If so, we can just update
- bookkeeping, and stage the file in git.
-}
addannexed :: [Change] -> Assistant [Maybe Change]
, checkWritePerms = True
}
if M.null m
- then forM toadd (addannexed' cfg)
+ then forM toadd $ \c -> do
+ mcache <- liftIO $ genInodeCache (changeFile c) delta
+ addunlocked <- checkaddunlocked c
+ addannexed' cfg c addunlocked mcache
else forM toadd $ \c -> do
mcache <- liftIO $ genInodeCache (changeFile c) delta
- case mcache of
- Nothing -> addannexed' cfg c
- Just cache ->
- case M.lookup (inodeCacheToKey ct cache) m of
- Nothing -> addannexed' cfg c
- Just k -> fastadd c k
-
- addannexed' :: LockDownConfig -> Change -> Assistant (Maybe Change)
- addannexed' lockdownconfig change@(InProcessAddChange { lockedDown = ld }) =
+ ifM (checkaddunlocked c)
+ ( case mcache of
+ Nothing -> addannexed' cfg c True Nothing
+ Just cache ->
+ case M.lookup (inodeCacheToKey ct cache) m of
+ Nothing -> addannexed' cfg c True Nothing
+ Just k -> fastadd c k
+ , addannexed' cfg c False mcache
+ )
+
+ checkaddunlocked (InProcessAddChange { lockedDown = ld }) =
+ case addunlockedmatcher of
+ Just addunlockedmatcher' -> do
+ let mi = MatchingFile $ FileInfo
+ { contentFile = contentLocation (keySource ld)
+ , matchFile = keyFilename (keySource ld)
+ , matchKey = Nothing
+ }
+ liftAnnex $ addUnlocked addunlockedmatcher' mi True
+ Nothing -> return True
+ checkaddunlocked _ = return True
+
+ addannexed' :: LockDownConfig -> Change -> Bool -> Maybe InodeCache -> Assistant (Maybe Change)
+ addannexed' lockdownconfig change@(InProcessAddChange { lockedDown = ld }) addunlocked mcache =
catchDefaultIO Nothing <~> doadd
where
ks = keySource ld
(mkey, _mcache) <- liftAnnex $ do
showStartMessage (StartMessage "add" (ActionItemOther (Just (QuotedPath (keyFilename ks)))) (SeekInput []))
ingest nullMeterUpdate (Just $ LockedDown lockdownconfig ks) Nothing
- maybe (failedingest change) (done change $ keyFilename ks) mkey
- addannexed' _ _ = return Nothing
+ maybe (failedingest change) (done change addunlocked mcache $ keyFilename ks) mkey
+ addannexed' _ _ _ _ = return Nothing
fastadd :: Change -> Key -> Assistant (Maybe Change)
fastadd change key = do
let source = keySource $ lockedDown change
liftAnnex $ finishIngestUnlocked key source
- done change (keyFilename source) key
+ done change True Nothing (keyFilename source) key
removedKeysMap :: InodeComparisonType -> [Change] -> Annex (M.Map InodeCacheKey Key)
removedKeysMap ct l = do
liftAnnex showEndFail
return Nothing
- done change file key = liftAnnex $ do
+ done change addunlocked mcache file key = liftAnnex $ do
logStatus NoLiveUpdate key InfoPresent
- mode <- liftIO $ catchMaybeIO $
- fileMode <$> R.getFileStatus (fromOsPath file)
- stagePointerFile file mode =<< hashPointerFile key
+ if addunlocked
+ then do
+ mode <- liftIO $ catchMaybeIO $
+ fileMode <$> R.getFileStatus (fromOsPath file)
+ stagePointerFile file mode =<< hashPointerFile key
+ else addSymlink file key mcache
showEndOk
return $ Just $ finishedChange change key
, annexSkipUnknown :: Bool
, annexAdjustedBranchRefresh :: Integer
, annexSupportUnlocked :: Bool
+ , annexAssistantAllowUnlocked :: Bool
, coreSymlinks :: Bool
, coreSharedRepository :: SharedRepository
, coreQuotePath :: QuotePath
(if getbool "adjustedbranchrefresh" False then 1 else 0)
(getmayberead (annexConfig "adjustedbranchrefresh"))
, annexSupportUnlocked = getbool (annexConfig "supportunlocked") True
+ , annexAssistantAllowUnlocked = getbool (annexConfig "assistant.allowunlocked") False
, coreSymlinks = getbool "core.symlinks" True
, coreSharedRepository = getSharedRepository r
, coreQuotePath = QuotePath (getbool "core.quotepath" True)
To configure a default annex.addunlocked for all clones of the repository,
this can be set in [[git-annex-config]](1).
- (Using `git add` always adds files in unlocked form and it is not
- affected by this setting.)
+ Using `git add` always adds files in unlocked form and it is not
+ affected by this setting. The assistant defaults to adding all files
+ unlocked, unless `annex.assistant.allowunlocked` is set.
When a repository has core.symlinks set to false, or has an adjusted
unlocked branch checked out, this setting is ignored, and files are
always added to the repository in unlocked form.
+* `annex.assistant.allowunlocked`
+
+ The `git-annex assistant` defaults to adding all files unlocked, so that
+ files can be modified without the user needing to do anything to unlock
+ them.
+
+ If this is set to `true` then it will instead use the `annex.addunlocked`
+ configuration to decide which files to add unlocked.
+
* `annex.numcopies`
This is a deprecated setting. You should instead use the